const app = getApp()
const parse = require('mini-html-parser2')
const {
  upTime
} = require('/util/public')
Page({
  data: {
    phonenumber: '',
    timeshow: [],
    indexss: '',
    timeorder: '',
    showpriceday: '',
    cnxh: '',
    appQuerysshow: false,
    appQuerys: '',
    daypricesss: '',
    sumdate: '',
    firstPayPeriod: '',
    showssss: false,
    textcnxh: '',
    totalBuyCount: '1',
    totalBuyCounts: '1',
    worryMoneys: '',
    dayprice: '',
    couponlist: [],
    lqshowings: false,
    zdyshow: false,
    wmoey: '',
    appQuery: '',
    comSelectshow: false, //一期
    comSelectshows: false, //会员 无忧保障
    comSelectshowss: false, //百事13pm
    comSelectshowsss: false, //5+1
    comSelectshowssss: false, //结算产品
    types: 0,
    content1: '',
    shopids: '',
    querys: '',
    content2: '',
    clicks: true,
    listpl: [],
    showCentents: false,
    showsss: false,
    marquee: 0, //每次移动X坐标
    windowWidth: 0, //小程序宽度
    maxScroll: 0, //文本移动至最左侧宽度及文本宽度
    newprice: [],
    newprice2: [],
    numone: 1.2,
    numtwo: 2.2,
    interval: '',
    addresss: '',
    Provinces: '',
    Citys: '',
    systemInfoheight: '',
    Countrys: '',
    loginShow: false,
    remmondImg: 'https://static.yirenzuji.com/upload/20211115/47d2faf2062840e7ac1f2d2666de64da.png',
    // 当前轮播图索引
    current: 0,
    // 租赁说明相关
    others: {
      icon: [{
          title: '租赁流程',
          icon: 'icon-shouji-copy'
        },
        {
          title: '租期计算',
          icon: 'icon-riqi'
        },
        {
          title: '租后方案',
          icon: 'icon-duanlashuoming'
        },
        {
          title: '人行征信',
          icon: 'icon-pinzhibaozhang'
        },
      ],
      index: 0,
      img: [
        '../../../image/other/detail/icon_111.png',
        '../../../image/other/detail/icon_222.png',
        '../../../image/other/detail/icon_333.png',
        '../../../image/other/detail/icon_444.png'
      ]
    },
    // 商品详情相关
    detail: {
      tabs: [{
          title: '商品详情',
          subTitle: '爆款好物'
        },
        {
          title: '租赁说明',
          subTitle: '摄影航拍'
        },
        {
          title: '常见问题',
          subTitle: '品质生活'
        },
        // { title: '商品评价', subTitle: '品质生活' },
      ],
    },

    activeTab: 0,

    // fontIcon
    fontIcon: [{
        title: '首页',
        color: '#333',
        tab: 'switchTabHome',
        icon: "../../../image/otherImg/shouye_buy.png"
      },
      // {title:'店铺',color:'#E6A93E',tab:'navigateTo',icon:"icon-shangpu"},
      {
        title: '客服',
        color: '#333',
        tab: 'servesr',
        icon: "../../../image/otherImg/kefu_buy.png"
      },
    ],
    // 弹窗
    showCentent: false,
    combo: {
      cobIndex: 0, // 套餐
      setIndex: null, // 套餐
      terIndex: 0, // 租期
      verIndex: 0, // 版本
      colIndex: 0, // 颜色
      insIndex: 0, // 碎屏
    }
  },
  onShow() {
    // let appQuery = my.getLaunchOptionsSync();


    // let appQuerys = my.getEnterOptionsSync();


    // if (appQuery.query && appQuery.query.param != '') {

    //   this.onloads(appQuery.query)
    //   return false
    // }
    // if (appQuerys.query && appQuery.query.param != '') {
    //   this.onloads(appQuerys.query)
    // }
    let timestamp = new Date().getTime()
    console.log("222", timestamp)
    var times = upTime("%Y-%M-%D %h:%m:%s", timestamp)
    console.log("7777777777", times)
    this.setData({
      nowtimes: times,
      phonenumber: '4008856357'
    })
    //  this.config();
    this.comment()
  },
  appQuerysshow() {
    this.setData({
      appQuerysshow: true
    })
  },
  onloads(query) {

    query.param = JSON.parse(query.param)
    console.log("111", query)
    this.setData({
      query: query, //{id:商品id}
      querys: JSON.parse(query.param),

    });
    //携带参数进入商品 
    if (query.flowState && query.promotionAccount) {
      app.globalData.flowState = query.flowState
      app.globalData.promotionAccount = query.promotionAccount
      let datas = {}
      datas.promotionAccount = query.promotionAccount
      datas.flowState = query.flowState
      my.setStorage({
        key: 'promotionAccount',
        data: datas,
      })
    }
    this.getdetail(query.param)
    app._init_(this)
    this.getHome();
    this.getSystemInfo()
  },
  onLoad(query) {
    console.log("555---", query)
    if (query.param) {

    } else {
      let appQuery = my.getLaunchOptionsSync();


      let appQuerys = my.getEnterOptionsSync();


      if (appQuery.query) {

        query = appQuery.query

      }
      if (appQuerys.query) {
        query = appQuerys.query
      }
    }



    console.log("111++++++", query)
    query.param = JSON.parse(query.param)
    console.log("111", query)
    this.setData({
      query: query, //{id:商品id}
      querys: JSON.parse(query.param),

      //给声明的变量interval赋值，每1000毫秒执行一次


    });
    //携带参数进入商品 
    if (query.flowState && query.promotionAccount) {
      app.globalData.flowState = query.flowState
      app.globalData.promotionAccount = query.promotionAccount
      let datas = {}
      datas.promotionAccount = query.promotionAccount
      datas.flowState = query.flowState
      my.setStorage({
        key: 'promotionAccount',
        data: datas,
      })
    }
    this.getdetail(query.param)
    app._init_(this)
    this.getHome();
    this.getSystemInfo()

  },
  couponadd(e) {
    console.log("111", e)
    let json = {}
    json.couponId = e.target.dataset.id
    app.order.couponadd(json)
      .then(res => {
        console.log("领取优惠券", res)
        if (res.code == '0') {
          my.showToast({
            content: '领取成功！',
          });
          this.lqshowing()
          //  this.setData({
          //    indexss: e.target.dataset.index
          //  })
        } else {
          my.showToast({
            content: res.msg,
          });
        }

      })
  },
  minusPreCountnum() { //租赁数量
    var that = this;
    if (that.data.totalBuyCounts > 1) {
      var totalBuyCounts = --that.data.totalBuyCounts;
      that.setData({
        totalBuyCounts: totalBuyCounts
      });
    }
  },
  minusPreCount() {
    var that = this;
    if (that.data.totalBuyCount > 1) {
      var totalBuyCount = --that.data.totalBuyCount;
      that.setData({
        totalBuyCount: totalBuyCount
      });
    }
  },
  navsss() {
    my.navigateTo({
      url: '/pages/product/plpage/plpage?param=' + this.data.querys
    });
  },
  handleBuyGoodsCountChanges(even) {
    console.log("222", even)
    if (even.detail.value < 0) {
      my.showToast({
        type: 'exception',
        content: '租赁数量不能小于1',
      });
      this.setData({
        totalBuyCounts: 1
      })
    } else {
      this.setData({
        totalBuyCounts: even.detail.value
      })
    }
  },
  handleBuyGoodsCountChange(even) {
    console.log("222", even)
    if (even.detail.value < 0) {
      my.showToast({
        type: 'exception',
        content: '租期不能小于1',
      });
      this.setData({
        totalBuyCount: 1
      })
    }
    if (even.detail.value > 11) {
      my.showToast({
        type: 'exception',
        content: '租期不能大于11',
      });
      this.setData({
        totalBuyCount: 1
      })
    }
  },
  addPreCount() {
    var that = this;
    if (that.data.totalBuyCount < 11) {
      var totalBuyCount = ++that.data.totalBuyCount;
      that.setData({
        totalBuyCount: totalBuyCount
      });
    }
  },
  addPreCountnum() {
    var that = this;

    var totalBuyCounts = ++that.data.totalBuyCounts;
    that.setData({
      totalBuyCounts: totalBuyCounts
    });

  },
  second(e) {
    ////console.log("3333",e)

    my.navigateTo({
      url: '../../product/second/second?data=' + e.currentTarget.dataset.id
    });
  },
  getSystemInfo() {
    my.getSystemInfo({
      success: (res) => {
        //console.log("设备详情", res)
        this.setData({
          systemInfoheight: res.windowHeight
        })
      }
    })
  },
  gopage() {
    my.navigateTo({
      url: '/pages/order/explain/explain'
    });
  },
  scrolltxt() {
    var t = this;
    var d = t.data;

    var interval = setInterval(function () {

      var next = d.marquee - 2; //每次移动距离
      if (next < 0 && Math.abs(next) > d.maxScroll) {
        next = d.windowWidth;
        clearInterval(interval);
        t.scrolltxt();
      }
      d.marquee = next;
      t.setData({
        marquee: next,

      });


    }, 80);



  },
  // api
  // 获取商品详情
  getdetail(id) {
    app.product.detail(id)
      .then(json => {
        console.log("***0", json)


        setTimeout(() => {

          if (json.data.shops.tit == '百事租机' && json.data.tit == '苹果iPhone13pro max' && json.data.shops.tit != '千兆租赁') {
            this.setData({
              comSelectshowss: true
            })
          } else {
            this.setData({
              comSelectshowss: false
            })
          }

          this.setData({
            types: json.data.productType
          })
          this.comSelectss({
            key: 'insIndex',
            value: json.data.smash
          });
          this.comSelectss({
            key: 'setIndex',
            value: null
          })
          var w = my.getSystemInfoSync().windowWidth - 100;
          var str = '本平台不对18岁以下未成年用户下单！租租乐服务时间：周一至周日9:30～21:30';
          this.setData({
            marquee: w
          });
          this.data.maxScroll = str.length * 15 - 100;
          this.data.windowWidth = w;
          this.scrolltxt();
        }, 1000)
        console.log("@@@", json.data)
        json.data.category = JSON.parse(json.data.category)
        json.data.colors = JSON.parse(json.data.colors)
        // json.data.otherParam = JSON.parse(json.data.otherParam)
        json.data.match = JSON.parse(json.data.match)
        json.data.params = JSON.parse(json.data.params)
        json.data.params.sort((a, b) => {
          if (a.name == '租完归还') {
            return 1
          } else {
            return -1
          }
        })
        let combo = this.data.combo
        combo.cobIndex = json.data.params.length - 1
        console.log("combo", combo);
        this.setData({
          combo,
          shopids: json.data.id
        })
        json.data.slideshows = JSON.parse(json.data.slideshows)
        json.data.msg = `${json.data.tit}`
        json.data.image = json.data.slideshows[0]
        let html = json.data.content
        html = html.replace(/<img>*/gi, '</img><img  style="display:block;width:750rpx!important; height:unset!important" ')
        html = html.replace(/<br>*/gi, '<br></br>')
        html = html.replace(/<\/?picture>*/gi, '')
        html = html.replace(/>\/>*/gi, ">")
        console.log("11112234", html)
        parse(html, (err, nodes) => {
          if (!err) {
            this.nodesChange(nodes)
            this.setData({
              nodes
            });
          }
        });
        this.setData({
          data: json.data
        });

        console.log("2222222222222222222777777777777777777777", json)
        let params = {
          tit: ""
        }
        if (json.data.productType == '3') {
          params.tit = (json.data.params).reverse()
        } else {
          params.tit = json.data.params
        }

        //console.log("4444", (params.tit[combo.cobIndex].term_list[combo.terIndex].specifications[combo.verIndex].money / (params.tit[combo.cobIndex].term_list[combo.terIndex].value * 100)).toFixed(2))
        var splitPrice = (params.tit[combo.cobIndex].term_list[combo.terIndex].specifications[combo.verIndex].money / (params.tit[combo.cobIndex].term_list[combo.terIndex].value * 100)).toFixed(2).split(".");
        // console.log("5655", params)
        if (json.data.productType == '6') {
          var splitPrice = ((params.tit[combo.cobIndex].term_list[combo.terIndex].specifications[combo.verIndex].money - params.tit[combo.cobIndex].term_list[combo.terIndex].specifications[combo.verIndex].worryMoney) / (params.tit[combo.cobIndex].term_list[combo.terIndex].value * 100)).toFixed(2).split(".");
        }

        this.setData({
          params: params,
          newprice: splitPrice[0],
          newprice2: splitPrice[1],
        });
      })
      .catch((err) => {
        console.log("yicahng ", err)
        if (err.code == '102') {
          my.alert({
            title: '亲',
            content: '该商品已下架',
            buttonText: '我知道了',
            success: () => {
              my.navigateBack();
            }
          });
          return
        } else {
          my.alert({
            title: '亲',
            content: '产品异常',
            buttonText: '我知道了',
            success: () => {
              my.navigateBack();
            }
          });
          return
        }
      })

  },
  getArea(str) {

    let area = {}
    let index11 = 0
    let index1 = str.indexOf("省")
    if (index1 == -1) {
      index11 = str.indexOf("自治区")
      if (index11 != -1) {
        area.Province = str.substring(0, index11 + 3)
      } else {
        area.Province = str.substring(0, 0)
      }
    } else {
      area.Province = str.substring(0, index1 + 1)
    }

    let index2 = str.indexOf("市")
    if (index11 == -1) {
      area.City = str.substring(index11 + 1, index2 + 1)
    } else {
      if (index11 == 0) {
        area.City = str.substring(index1 + 1, index2 + 1)
      } else {
        area.City = str.substring(index11 + 3, index2 + 1)
      }
    }

    let index3 = str.lastIndexOf("区")
    if (index3 == -1) {
      index3 = str.indexOf("县")
      area.Country = str.substring(index2 + 1, index3 + 1)
    } else {
      area.Country = str.substring(index2 + 1, index3 + 1)
    }
    //console.log("678uio9", area)
    this.setData({
      addresss: area
    })
  },
  nodesChange(nodes) {
    if (!nodes) {
      return
    };
    nodes.forEach(item => {
      if (item.name == "img") {
        item.children = []
      } else {
        this.nodesChange(item.children)
      }
    });
  },

  getshopinfo(sid) {
    let timestamp = new Date().getTime()
    app.product.shops(sid)
      .then(res => {
        //console.log("====shop-info=======>>>>>>>>>>",res)
        let cloudService = res.data.cloudService
        if (cloudService == null) {
          return
        }
        this.setData({
          cloudService: cloudService
        })
        //console.log(res)
      })
  },

  // login
  getUser() {
    //console.log("1111111111111111111")
    let user = my.getStorageSync({
      key: 'user'
    });
    //console.log("user", user)
    // 判断有没有登录
    if (!user.data) {
      //console.log("1111111111111111111")
      this.setData({
        loginShow: true,
      })
      return true
    }
  },
  login() {
    this.setData({
      loginShow: true
    })
  },

  onLgin(data) {
    this.setData(data)
  },

  // 确定
  // 商品数据传参
  onSubmit() {
    my.showLoading({
      content: '加载中...'
    });
    setTimeout(() => {
      my.hideLoading();
    }, 100)

    console.log("121223123123123", this.data.combo)
    if (this.getUser()) {
      return false
    }
    if (this.data.combo.setIndex == null) {
      my.alert({
        title: '亲',
        content: '请选择套餐哦！',
        buttonText: '我知道了'
      })
      return false
    }
    let {
      cobIndex,
      terIndex,
      verIndex,
      colIndex,
      insIndex
    } = this.data.combo

    let stock = this.data.params.tit[cobIndex].term_list[terIndex].specifications[verIndex].stock
    if (!parseInt(stock)) {
      my.alert({
        content: '该商品缺货中'
      });
      return false
    }
    my.getAuthCode({
      // 订单服务授权：order_service。如需同时获取用户多项授权，可在 scopes 中传入多个 scope 值。
      scopes: ['order_service'],
      success: (res) => {
        console.log("订单消息返回", this.data)
        const data = JSON.stringify({
          zlnum: this.data.totalBuyCounts,
          msg: this.data.data.msg, // 商品名
          id: this.data.data.id, // 商品id
          sid: this.data.data.sid,
          detail: `${this.data.params.tit[cobIndex].name} ${this.data.data.colors[colIndex].tit} ${this.data.params.tit[cobIndex].term_list[terIndex].specifications[verIndex].tit}`, // 套餐
          details: `${this.data.params.tit[cobIndex].name}`,
          detailss: `${this.data.data.colors[colIndex].tit}`,
          detailsss: `${this.data.params.tit[cobIndex].term_list[terIndex].specifications[verIndex].tit}`,
          trem: this.data.params.tit[cobIndex].term_list[terIndex].name, // 租期
          trem_value: this.data.params.tit[cobIndex].term_list[terIndex].value, // 租期
          slideshows: this.data.data.slideshows,
          worryMoney: this.data.params.tit[cobIndex].term_list[terIndex].specifications[verIndex].worryMoney, //
          outPrice: this.data.params.tit[cobIndex].term_list[terIndex].specifications[verIndex].outPrice, //
          neicun: this.data.params.tit[cobIndex].term_list[terIndex].specifications[verIndex].tit, //内存
          cash: this.data.params.tit[cobIndex].term_list[terIndex].specifications[verIndex].cash, //押金
          money: this.data.params.tit[cobIndex].term_list[terIndex].specifications[verIndex].money, //金额
          buyOut: this.data.params.tit[cobIndex].term_list[terIndex].specifications[verIndex].buyout, // 完结价
          extraInfo: this.data.data.extraInfo,
          // otherParam: this.data.data.otherParam,
          firstPayPeriod: this.data.params.tit[cobIndex].term_list[terIndex].specifications[verIndex].firstPayPeriod || 3,
          cashSum: this.data.params.tit[cobIndex].term_list[terIndex].specifications[verIndex].cash,
          cashPeriod: this.data.params.tit[cobIndex].term_list[terIndex].specifications[verIndex].cashPeriod,
          wangluo: this.data.data.category.wangluo, //网络
          color: this.data.data.colors[colIndex], // 颜色
          productType: this.data.data.productType,
          type: this.data.data.type, // 成色 0为新，1为二手
          match: {
            tit: this.data.data.match,
            value: this.data.match
          }, // 可选搭配
          smash: {
            tit: this.data.data.smash,
            value: insIndex
          }, //碎屏保障
          freight: this.data.freight ? '到付' : "到付",

          shops: this.data.data.shops
        });

        console.log("00000", data)
        if (this.data.shopids == '5089') {
          my.navigateTo({
            url: '/pages/order/ipon/ipon'
          })

        } else {
          if (this.data.types == '2') {
            // this.getinfo(data)
            my.navigateTo({
              url: "/pages/product/confirm/confirm?data=".concat(encodeURIComponent(data))
            });
          } else {
            my.navigateTo({
              url: "/pages/product/confirm/confirm?data=".concat(encodeURIComponent(data))
            });
          }

        }


      },
      fail: (res) => {
        // 订单服务授权失败，根据自己的业务场景来进行错误处理
        const data = JSON.stringify({
          zlnum: this.data.totalBuyCounts,
          msg: this.data.data.msg, // 商品名
          id: this.data.data.id, // 商品id
          sid: this.data.data.sid,
          detail: `${this.data.params.tit[cobIndex].name} ${this.data.data.colors[colIndex].tit} ${this.data.params.tit[cobIndex].term_list[terIndex].specifications[verIndex].tit}`, // 套餐
          details: `${this.data.params.tit[cobIndex].name}`,
          detailss: `${this.data.data.colors[colIndex].tit}`,
          detailsss: `${this.data.params.tit[cobIndex].term_list[terIndex].specifications[verIndex].tit}`,
          trem: this.data.params.tit[cobIndex].term_list[terIndex].name, // 租期
          trem_value: this.data.params.tit[cobIndex].term_list[terIndex].value, // 租期
          slideshows: this.data.data.slideshows,
          worryMoney: this.data.params.tit[cobIndex].term_list[terIndex].specifications[verIndex].worryMoney, //
          outPrice: this.data.params.tit[cobIndex].term_list[terIndex].specifications[verIndex].outPrice, //
          neicun: this.data.params.tit[cobIndex].term_list[terIndex].specifications[verIndex].tit, //内存
          cash: this.data.params.tit[cobIndex].term_list[terIndex].specifications[verIndex].cash, //押金
          money: this.data.params.tit[cobIndex].term_list[terIndex].specifications[verIndex].money, //金额
          buyOut: this.data.params.tit[cobIndex].term_list[terIndex].specifications[verIndex].buyout, // 完结价
          extraInfo: this.data.data.extraInfo,
          // otherParam: this.data.data.otherParam,
          firstPayPeriod: this.data.params.tit[cobIndex].term_list[terIndex].specifications[verIndex].firstPayPeriod || 3,
          cashSum: this.data.params.tit[cobIndex].term_list[terIndex].specifications[verIndex].cash,
          cashPeriod: this.data.params.tit[cobIndex].term_list[terIndex].specifications[verIndex].cashPeriod,
          wangluo: this.data.data.category.wangluo, //网络
          color: this.data.data.colors[colIndex], // 颜色
          productType: this.data.data.productType,
          type: this.data.data.type, // 成色 0为新，1为二手
          match: {
            tit: this.data.data.match,
            value: this.data.match
          }, // 可选搭配
          smash: {
            tit: this.data.data.smash,
            value: insIndex
          }, //碎屏保障
          freight: this.data.freight ? '到付' : "到付",

          shops: this.data.data.shops
        });

        console.log("00000", data)

        if (this.data.types == '2') {
          // this.getinfo(data)
          my.navigateTo({
            url: "/pages/product/confirm/confirm?data=".concat(encodeURIComponent(data))
          });
        } else {
          my.navigateTo({
            url: "/pages/product/confirm/confirm?data=".concat(encodeURIComponent(data))
          });
        }
      },
    })
    //console.log(cobIndex,terIndex,verIndex,colIndex,insIndex)

  },
  onSubmits() {
    my.showLoading({
      content: '加载中...'
    });
    setTimeout(() => {
      my.hideLoading();
    }, 100)

    console.log("121223123123123", this.data.combo)
    if (this.getUser()) {
      return false
    }
    let {
      cobIndex,
      terIndex,
      verIndex,
      colIndex,
      insIndex
    } = this.data.combo

    let stock = this.data.params.tit[cobIndex].term_list[terIndex].specifications[verIndex].stock
    console.log("12", stock)
    if (!parseInt(stock)) {
      my.alert({
        content: '该商品缺货中'
      });
      return false
    }
    my.getAuthCode({
      // 订单服务授权：order_service。如需同时获取用户多项授权，可在 scopes 中传入多个 scope 值。
      scopes: ['order_service'],
      success: (res) => {
        console.log("订单消息返回", this.data.data.extraInfo)
        const data = JSON.stringify({

          msg: this.data.data.msg, // 商品名
          id: this.data.data.id, // 商品id
          sid: this.data.data.sid,
          detail: `${this.data.params.tit[cobIndex].name} ${this.data.data.colors[colIndex].tit} ${this.data.params.tit[cobIndex].term_list[terIndex].specifications[verIndex].tit}`, // 套餐
          details: `${this.data.params.tit[cobIndex].name}`,
          detailss: `${this.data.data.colors[colIndex].tit}`,
          detailsss: `${this.data.params.tit[cobIndex].term_list[terIndex].specifications[verIndex].tit}`,
          trem: this.data.params.tit[cobIndex].term_list[terIndex].name, // 租期
          trem_value: this.data.params.tit[cobIndex].term_list[terIndex].value, // 租期
          newdata: this.data.totalBuyCount,
          slideshows: this.data.data.slideshows,
          worryMoney: this.data.params.tit[cobIndex].term_list[terIndex].specifications[verIndex].worryMoney, //
          outPrice: this.data.params.tit[cobIndex].term_list[terIndex].specifications[verIndex].outPrice, //
          neicun: this.data.params.tit[cobIndex].term_list[terIndex].specifications[verIndex].tit, //内存
          cash: this.data.params.tit[cobIndex].term_list[terIndex].specifications[verIndex].cash, //押金
          money: this.data.params.tit[cobIndex].term_list[terIndex].specifications[verIndex].money, //金额
          buyOut: this.data.params.tit[cobIndex].term_list[terIndex].specifications[verIndex].buyout, // 完结价
          extraInfo: this.data.data.extraInfo,
          // otherParam: this.data.data.otherParam,
          wangluo: this.data.data.category.wangluo, //网络
          color: this.data.data.colors[colIndex], // 颜色
          productType: this.data.data.productType,
          type: this.data.data.type, // 成色 0为新，1为二手
          match: {
            tit: this.data.data.match,
            value: this.data.match
          }, // 可选搭配
          smash: {
            tit: this.data.data.smash,
            value: insIndex
          }, //碎屏保障
          freight: this.data.freight ? '到付' : "到付",

          shops: this.data.data.shops
        });

        console.log("00000", data)

        if (this.data.types == '2') {
          // this.getinfo(data)
          my.navigateTo({
            url: "/pages/product/confirms/confirms?data=".concat(encodeURIComponent(data))
          });
        } else {
          my.navigateTo({
            url: "/pages/product/confirms/confirms?data=".concat(encodeURIComponent(data))
          });
        }


      },
      fail: (res) => {
        // 订单服务授权失败，根据自己的业务场景来进行错误处理
        console.log("订单消息返回", this.data.data.extraInfo)
        const data = JSON.stringify({

          msg: this.data.data.msg, // 商品名
          id: this.data.data.id, // 商品id
          sid: this.data.data.sid,
          detail: `${this.data.params.tit[cobIndex].name} ${this.data.data.colors[colIndex].tit} ${this.data.params.tit[cobIndex].term_list[terIndex].specifications[verIndex].tit}`, // 套餐
          details: `${this.data.params.tit[cobIndex].name}`,
          detailss: `${this.data.data.colors[colIndex].tit}`,
          detailsss: `${this.data.params.tit[cobIndex].term_list[terIndex].specifications[verIndex].tit}`,
          trem: this.data.params.tit[cobIndex].term_list[terIndex].name, // 租期
          trem_value: this.data.params.tit[cobIndex].term_list[terIndex].value, // 租期
          newdata: this.data.totalBuyCount,
          slideshows: this.data.data.slideshows,
          worryMoney: this.data.params.tit[cobIndex].term_list[terIndex].specifications[verIndex].worryMoney, //
          outPrice: this.data.params.tit[cobIndex].term_list[terIndex].specifications[verIndex].outPrice, //
          neicun: this.data.params.tit[cobIndex].term_list[terIndex].specifications[verIndex].tit, //内存
          cash: this.data.params.tit[cobIndex].term_list[terIndex].specifications[verIndex].cash, //押金
          money: this.data.params.tit[cobIndex].term_list[terIndex].specifications[verIndex].money, //金额
          buyOut: this.data.params.tit[cobIndex].term_list[terIndex].specifications[verIndex].buyout, // 完结价
          extraInfo: this.data.data.extraInfo,
          // otherParam: this.data.data.otherParam,
          wangluo: this.data.data.category.wangluo, //网络
          color: this.data.data.colors[colIndex], // 颜色
          productType: this.data.data.productType,
          type: this.data.data.type, // 成色 0为新，1为二手
          match: {
            tit: this.data.data.match,
            value: this.data.match
          }, // 可选搭配
          smash: {
            tit: this.data.data.smash,
            value: insIndex
          }, //碎屏保障
          freight: this.data.freight ? '到付' : "到付",

          shops: this.data.data.shops
        });

        console.log("00000", data)

        if (this.data.types == '2') {
          // this.getinfo(data)
          my.navigateTo({
            url: "/pages/product/confirms/confirms?data=".concat(encodeURIComponent(data))
          });
        } else {
          my.navigateTo({
            url: "/pages/product/confirms/confirms?data=".concat(encodeURIComponent(data))
          });
        }
      },
    })
    //console.log(cobIndex,terIndex,verIndex,colIndex,insIndex)

  },

  onSubmitss() {
    my.showLoading({
      content: '加载中...'
    });
    setTimeout(() => {
      my.hideLoading();
    }, 100)
    let {
      cobIndex,
      terIndex,
      verIndex,
      colIndex,
      insIndex
    } = this.data.combo
    if (this.data.sumdate != '') {

      var arr = []
      for (let i = 0; this.data.params.tit[cobIndex].term_list[i]; i++) {

        if (this.data.params.tit[cobIndex].term_list[i].value <= this.data.sumdate) {
          arr.push(i)

        }
        console.log("1111++", arr)
      }
      let wmoey = this.data.params.tit[cobIndex].term_list[arr[arr.length - 1]].specifications[verIndex].worryMoney
      let dayprice = (this.data.params.tit[cobIndex].term_list[arr[arr.length - 1]].specifications[verIndex].money - wmoey) / this.data.sumdate
      console.log("不卫龙", this.data.params, this.data.sumdate, dayprice)
      this.setData({
        wmoey: wmoey,
        dayprice: dayprice
      })
    } else {

      let wmoey = this.data.params.tit[cobIndex].term_list[terIndex].specifications[verIndex].worryMoney
      let dayprice = (this.data.params.tit[cobIndex].term_list[terIndex].specifications[verIndex].money - this.data.params.tit[cobIndex].term_list[terIndex].specifications[verIndex].worryMoney) / this.data.params.tit[cobIndex].term_list[terIndex].value
      this.setData({
        wmoey: wmoey,
        dayprice: dayprice
      })
    }
    console.log("不卫龙", this.data.params, this.data.sumdate)
    console.log("121223123123123", this.data.combo)



    if (this.getUser()) {
      return false
    }


    let stock = this.data.params.tit[cobIndex].term_list[terIndex].specifications[verIndex].stock
    console.log("12", stock)
    if (!parseInt(stock)) {
      my.alert({
        content: '该商品缺货中'
      });
      return false
    }
    my.getAuthCode({
      // 订单服务授权：order_service。如需同时获取用户多项授权，可在 scopes 中传入多个 scope 值。
      scopes: ['order_service'],
      success: (res) => {
        console.log("订单消息返回", this.data.data.extraInfo)
        const data = JSON.stringify({
          zlnum: this.data.totalBuyCounts,
          msg: this.data.data.msg, // 商品名
          id: this.data.data.id, // 商品id
          sid: this.data.data.sid,
          detail: `${this.data.params.tit[cobIndex].name} ${this.data.data.colors[colIndex].tit} ${this.data.params.tit[cobIndex].term_list[terIndex].specifications[verIndex].tit}`, // 套餐
          details: `${this.data.params.tit[cobIndex].name}`,
          detailss: `${this.data.data.colors[colIndex].tit}`,
          detailsss: `${this.data.params.tit[cobIndex].term_list[terIndex].specifications[verIndex].tit}`,
          trem: this.data.sumdate == '' ? this.data.params.tit[cobIndex].term_list[terIndex].name : this.data.sumdate, // 租期
          trem_value: this.data.sumdate == '' ? this.data.params.tit[cobIndex].term_list[terIndex].value : this.data.sumdate, // 租期
          slideshows: this.data.data.slideshows,
          worryMoney: this.data.wmoey == '' ? this.data.params.tit[cobIndex].term_list[terIndex].specifications[verIndex].worryMoney : this.data.wmoey, //
          // otherParam: this.data.data.otherParam,
          outPrice: this.data.params.tit[cobIndex].term_list[terIndex].specifications[verIndex].outPrice, //
          neicun: this.data.params.tit[cobIndex].term_list[terIndex].specifications[verIndex].tit, //内存
          cash: this.data.params.tit[cobIndex].term_list[terIndex].specifications[verIndex].cash, //押金
          money: this.data.params.tit[cobIndex].term_list[terIndex].specifications[verIndex].money, //金额
          buyOut: this.data.params.tit[cobIndex].term_list[terIndex].specifications[verIndex].buyout, // 完结价
          extraInfo: this.data.data.extraInfo,
          showpriceday: this.data.showpriceday,
          worryMoneys: this.data.worryMoneys,
          dayprice: this.data.dayprice,
          wangluo: this.data.data.category.wangluo, //网络
          color: this.data.data.colors[colIndex], // 颜色
          productType: this.data.data.productType,
          type: this.data.data.type, // 成色 0为新，1为二手
          match: {
            tit: this.data.data.match,
            value: this.data.match
          }, // 可选搭配
          smash: {
            tit: this.data.data.smash,
            value: insIndex
          }, //碎屏保障
          freight: this.data.freight ? '到付' : "到付",

          shops: this.data.data.shops
        });

        console.log("00000", data)

        if (this.data.types == '2') {
          // this.getinfo(data)
          my.navigateTo({
            url: "/pages/product/confirmss/confirmss?data=".concat(encodeURIComponent(data))
          });
        } else {
          my.navigateTo({
            url: "/pages/product/confirmss/confirmss?data=".concat(encodeURIComponent(data))
          });
        }


      },
      fail: (res) => {
        // 订单服务授权失败，根据自己的业务场景来进行错误处理
        console.log("订单消息返回", this.data.data.extraInfo)
        const data = JSON.stringify({
          zlnum: this.data.totalBuyCounts,
          msg: this.data.data.msg, // 商品名
          id: this.data.data.id, // 商品id
          sid: this.data.data.sid,
          detail: `${this.data.params.tit[cobIndex].name} ${this.data.data.colors[colIndex].tit} ${this.data.params.tit[cobIndex].term_list[terIndex].specifications[verIndex].tit}`, // 套餐
          details: `${this.data.params.tit[cobIndex].name}`,
          detailss: `${this.data.data.colors[colIndex].tit}`,
          detailsss: `${this.data.params.tit[cobIndex].term_list[terIndex].specifications[verIndex].tit}`,
          trem: this.data.sumdate == '' ? this.data.params.tit[cobIndex].term_list[terIndex].name : this.data.sumdate, // 租期
          trem_value: this.data.sumdate == '' ? this.data.params.tit[cobIndex].term_list[terIndex].value : this.data.sumdate, // 租期
          slideshows: this.data.data.slideshows,
          worryMoney: this.data.wmoey == '' ? this.data.params.tit[cobIndex].term_list[terIndex].specifications[verIndex].worryMoney : this.data.wmoey, //
          outPrice: this.data.params.tit[cobIndex].term_list[terIndex].specifications[verIndex].outPrice, //
          neicun: this.data.params.tit[cobIndex].term_list[terIndex].specifications[verIndex].tit, //内存
          cash: this.data.params.tit[cobIndex].term_list[terIndex].specifications[verIndex].cash, //押金
          money: this.data.params.tit[cobIndex].term_list[terIndex].specifications[verIndex].money, //金额
          buyOut: this.data.params.tit[cobIndex].term_list[terIndex].specifications[verIndex].buyout, // 完结价
          extraInfo: this.data.data.extraInfo,
          showpriceday: this.data.showpriceday,
          // otherParam: this.data.data.otherParam,
          worryMoneys: this.data.worryMoneys,
          dayprice: this.data.dayprice,
          wangluo: this.data.data.category.wangluo, //网络
          color: this.data.data.colors[colIndex], // 颜色
          productType: this.data.data.productType,
          type: this.data.data.type, // 成色 0为新，1为二手
          match: {
            tit: this.data.data.match,
            value: this.data.match
          }, // 可选搭配
          smash: {
            tit: this.data.data.smash,
            value: insIndex
          }, //碎屏保障
          freight: this.data.freight ? '到付' : "到付",

          shops: this.data.data.shops
        });

        console.log("00000", data)

        if (this.data.types == '2') {
          // this.getinfo(data)
          my.navigateTo({
            url: "/pages/product/confirmss/confirmss?data=".concat(encodeURIComponent(data))
          });
        } else {
          my.navigateTo({
            url: "/pages/product/confirmss/confirmss?data=".concat(encodeURIComponent(data))
          });
        }
      },
    })
    //console.log(cobIndex,terIndex,verIndex,colIndex,insIndex)

  },

  onHide() {
    console.log("yincang", )

    my.hideLoading();
  },
  // swiperChange
  swiperChange(e) {
    const current = e.detail.current
    this.setData({
      current
    })
  },
  getinfo(options) {
    console.log("optionsoptionsoptions", options)
    let that = this;
    var infor = options;
    let e = {};
    e.uid = my.getStorageSync({
      key: 'user'
    }).data.id;
    app.order.getinfo(e)
      .then(res => {
        console.log("查询信息", res)
        if (res.data == null) {
          my.alert({
            title: '亲',
            content: '请先开会员卡哦！',
            buttonText: '我知道了',
            success: () => {
              my.navigateTo({
                url: '/pages/order/ordervip/ordervip',
                success: () => {

                },
                fail: () => {

                },
                complete: () => {

                }
              });
            }
          });


          console.log("没开")
        } else {
          my.navigateTo({
            url: "/pages/product/confirm/confirm?data=".concat(encodeURIComponent(infor))
          });
          console.log("开了")
        }
      })
  },
  // other 
  otherClick(e) {
    let others = this.data.others
    others.index = e.target.dataset.index
    this.setData({
      others
    })
  },

  // tabs
  handleTabClick({
    index,
    tabsName
  }) {

    this.setData({
      [tabsName]: index,
    });
    if (index == 3) {


    }
  },
  comment() {
    // productId
    let e = {};
    e.page = false;
    e.productId = this.data.querys;
    // app.order.commentlist(e)
    //   .then(res => {
    //     console.log("22222", res)
    //     res.data.forEach((json) => {
    //       //   console.log("一元首月1", json)
    //       json.heards = JSON.parse(json.heard)
    //       json.imgss = JSON.parse(json.imgs)
    //       json.name = json.updatedBy.substring(0, 1)

    //     })
    //     console.log("1111", res)
    //     this.setData({
    //       listpl: res.data
    //     })
    //   })
  },
  // popup
  onPopupOpen() {
    let combo = this.data.combo;
    combo.cobIndex = 0;
    this.setData({
      showCentent: true,
      combo: combo
    });
  },
  previewImage(e) {
    console.log("22222", e)
    my.previewImage({
      current: 0,
      urls: [
        e.currentTarget.dataset.url
      ],
    });
  },
  onPopupCloselq() {

    this.setData({
      lqshowings: false
    });
  },
  lqshowing() {
    let e = {}
    e.status = 1
    e.page = false
    app.order.couponlist(e)
      .then(res => {
        console.log("2222", res)
        if (res.code == '0') {
          // nodes.forEach(item => {
          // }
          console.log("66", res.data)
          let arr = res.data.filter(item => {
            return (item.type == '1' || item.productId == this.data.shopids)

          })
          console.log("66", arr)
          this.setData({
            lqshowings: true,
            couponlist: arr

          });

        }
      })


  },
  onPopupClose() {
    this.setData({
      showCentent: false
    });
  },
  onPopupCloses() {
    this.setData({
      showsss: false
    });
  },
  onPopupClosess() {
    this.setData({
      showssss: false
    });
  },
  showyj() {
    this.setData({
      showssss: true
    });
  },
  onPopupClosese() {
    this.setData({
      showCentents: false
    });
  },
  up_showing() {
    this.setData({
      showCentents: true
    });
  },
  getHome() {

    app.other.home().then(res => {

      this.setData({
        cnxh: JSON.parse(res.data.eventsGoods).prudects
      })

      // this.dataPromise(love).then(json => {


      //   res.data.love.plist = json
      //   this.setData({
      //     cnxh: res.data,
      //     // timeorder: res.data.beginDate.plist[0].tit,
      //     // interval: setInterval(() => {
      //     //   this.setTimer()
      //     // }, 1000)
      //   })
      // })

    })
  },
  // 转价格
  dataPromise(list) {
    return new Promise((relose, reject) => {





      list.forEach((item) => {
        this.getminPrice(item.params)
          .then(res => {

            item.price = res
          })
      })

      relose(list)
    })
  },

  getminPrice(params) {
    return new Promise((resole, reject) => {
      let prices = []
      for (let i = 0; i < params.length; i++) {
        for (let t = 0; t < params[i].term_list.length; t++) {
          for (let s = 0; s < params[i].term_list[t].specifications.length; s++) {
            let price = (params[i].term_list[t].specifications[s].money / params[i].term_list[t].value / 100).toFixed(2)
            prices.push(price)
          }
        }
      }
      let minprice = Math.min.apply(null, prices);
      resole(minprice)
    })
  },
  setTimer() {
    var timestamp = new Date().getTime();
    console.log("555", timestamp)
    var nowtime = upTime("%Y-%M-%D %h:%m:%s", timestamp)
    var beginDate = new Date(upTime("%Y-%M-%D %h:%m:%s", this.data.timeorder));
    var endDate = new Date(nowtime);
    console.log("1111888+++", beginDate)
    console.log("1111888", endDate)
    console.log("1111888--", endDate.getTime() - beginDate.getTime())
    var diff = beginDate.getTime() - endDate.getTime();
    var sjc = diff / 1000;
    console.log("111", sjc)

    if (sjc > 0) {
      var showtimg = this.getTime(sjc)
      console.log("----", showtimg)
      this.setData({
        timeshow: showtimg,

      })

    } else {
      clearInterval(this.data.interval)




    }
    // setTimeout(this.setTimer(), 3000);

  },
  getTime(time) {
    // 转换为式分秒
    let h = parseInt(time / 60 / 60)
    h = h < 10 ? '0' + h : h
    let m = parseInt(time / 60 % 60)
    m = m < 10 ? '0' + m : m
    let s = parseInt(time % 60)
    s = s < 10 ? '0' + s : s
    // 作为返回值返回
    //  setTimeout(this.setTimer(), 1000)
    return [h, m, s]

  },
  comSelect(e) {
    console.log("11111111111111", e)
    console.log("--------", Object.keys(e).length)

    if (e.currentTarget.dataset.infor == '自定义') {
      this.setData({
        zdyshow: true,
        showCalendar: true,
        clicks: true
      })
    } else {

      this.setData({
        sumdate: '',
        clicks: false
      })

      if (Object.keys(e).length == '2') {
        //console.log("1111111111111111111111111111111111111111111111111111",e)
        let {
          key,
          value
        } = e;

        let combo = {
          cobIndex: 0, // 套餐
          setIndex: null, //套餐1
          terIndex: 0, // 租期
          verIndex: 0, // 版本
          colIndex: 0, // 颜色
          insIndex: this.data.combo.insIndex, // 碎屏

        };
        //console.log("!!!!!!!!@@@@@",key)
        console.log("$$$$$$$$$$$$$", combo)
        //console.log("、、、、、、、、、", { key, value } )
        if (key == 'insIndex') {
          if (combo.insIndex != 0) {
            combo[key] = 0
          } else {
            combo[key] = value
          }
        } else {
          combo[key] = value
        }
        this.setData({
          combo
        })
      } else {
        let {
          key,
          value
        } = e.target.dataset.item;
        let combo = this.data.combo;
        if (key == 'insIndex') {
          if (combo.insIndex != 0) {
            combo[key] = 0
          } else {
            combo[key] = value
          }
        } else if (key == "setIndex") {
          console.log("8888888888", key)
          console.log("999999999", value)
          console.log("1010101010", combo.setIndex);
          if (combo.setIndex == null) {
            combo.setIndex = value
            combo["cobIndex"] = value
          } else if (combo.setIndex == value) {
            combo.setIndex = null
          } else if (combo.setIndex != value) {
            combo.setIndex = value
            combo["cobIndex"] = value
          }
        } else {
          combo[key] = value
        }
        this.setData({
          combo
        })
        //console.log("999999999999999", combo)
      }
    }
  },
  comSelectss(e) {
    console.log("11111111111111", e)
    console.log("--------", Object.keys(e).length)
    if (Object.keys(e).length == '2') {
      console.log("1111111111111111111111111111111111111111111111111111", e)
      let {
        key,
        value
      } = e;

      let combo = {
        setIndex: null, //套餐
        cobIndex: 0, // 套餐
        terIndex: 0, // 租期
        verIndex: 0, // 版本
        colIndex: 0, // 颜色
        insIndex: this.data.combo.insIndex, // 碎屏

      };
      if (key == 'insIndex') {
        if (combo.insIndex != 0) {
          combo[key] = 0
          console.log("^^^^^^^^^^^^^^^^^^", combo[key], value)
        } else {
          combo[key] = value
          console.log("(((((((((((((((((((((((", combo[key], value)
        }
      } else if (key == "setIndex") {
        if (combo.setIndex != 0) {
          combo[key] = null
        } else {
          combo[key] = null
        }
      } else {
        combo[key] = value
      }
      this.setData({
        combo
      })
    } else {
      let {
        key,
        value
      } = e.target.dataset.item;
      let combo = this.data.combo;
      if (key == 'insIndex') {
        if (combo.insIndex != 0) {
          combo[key] = 0
        } else {
          combo[key] = value
        }
      } else {
        combo[key] = value
      }
      this.setData({
        combo
      })
    }
  },


  // 跳转
  navigateTo(e) {
    app.navigateTo(e)
  },
  config() {

    var that = this;
    app.other.config()
      .then(res => {
        console.log("444:", res.data.data);
        console.log("444:", res.data.data[0].content / 10000);


        let numone = res.data.data.filter(it => {
          return it.name == "collect_person_num"
        })[0];
        let numtwo = res.data.data.filter(it => {
          return it.name == "care_person_num"
        })[0];
        console.log("!!!!!!!!!!!", numone)
        that.setData({

          numtwo: (numtwo.content / 10000).toFixed(2),
          numone: (numone.content / 10000).toFixed(2)
        })

      })




  },
  edit(numone, numtwo) {
    console.log("this.data.content1", numone, numtwo)
    numone.content = Number(numone.content) + 0.5
    app.other.edit(numone)
      .then(res => {
        console.log("响应码111:", res);
        if (res.code == '0') {
          this.edits(numtwo)
        }
      })

  },
  edits(numtwo) {
    console.log("this.data.content1", Number(this.data.content2) + 0.5)
    numtwo.content = Number(numtwo.content) + 0.5
    app.other.edit(numtwo)
      .then(res => {
        console.log("响应码:", res);

      })

  },
  // 首页
  switchTabHome() {
    my.switchTab({
      url: "/pages/main/home/home"
    })
  },
  // 客服
  server() {
    //console.log("222222222222222")
    my.makePhoneCall({
      number: '4008856357'
    });
  },
  servesr() {

    this.setData({
      showsss: true
    })
  },
  closeFunc() {
    this.setData({
      showCalendar: false,
      zdyshow: false
    })
  },
  selectTime() {
    this.setData({
      showCalendar: true
    })
  },
  changeDate(data) {
    console.log(data, "]]]]]返回数据]]]]]]")
    let dates = this.DateDiff(data.endDate, data.startDate)
    let {
      cobIndex,
      terIndex,
      verIndex,
      colIndex,
      insIndex
    } = this.data.combo
    var arr = []
    for (let i = 0; this.data.params.tit[cobIndex].term_list[i]; i++) {

      if (this.data.params.tit[cobIndex].term_list[i].value <= Number(dates + 1)) {
        arr.push(i)

      }
      console.log("1111++", arr)
    }
    let wmoey = this.data.params.tit[cobIndex].term_list[arr[arr.length - 1]].specifications[verIndex].worryMoney
    let dayprice = (this.data.params.tit[cobIndex].term_list[arr[arr.length - 1]].specifications[verIndex].money - wmoey) / Number(dates + 1)
    console.log("不卫龙", this.data.params, Number(dates + 1), dayprice)
    this.setData({
      daypricesss: dayprice
    })
    let leaseTermss = ''

    if (Number(dates + 1) <= 30) {

      leaseTermss = 1
    } else if (60 >= Number(dates + 1) && Number(dates + 1) > 30) {
      leaseTermss = 2
    } else if (90 >= Number(dates + 1) && Number(dates + 1) > 60) {
      console.log("shide ")
      leaseTermss = 3
    } else if (120 >= Number(dates + 1) && Number(dates + 1) > 90) {
      leaseTermss = 4
    } else if (150 >= Number(dates + 1) && Number(dates + 1) > 120) {
      leaseTermss = 5
    } else if (180 >= Number(dates + 1) && Number(dates + 1) > 150) {
      leaseTermss = 6
    } else if (210 >= Number(dates + 1) && Number(dates + 1) > 180) {
      leaseTermss = 7
    } else if (240 >= Number(dates + 1) && Number(dates + 1) > 210) {
      leaseTermss = 8
    } else if (270 >= Number(dates + 1) && Number(dates + 1) > 240) {
      leaseTermss = 9
    } else if (300 >= Number(dates + 1) && Number(dates + 1) > 270) {
      leaseTermss = 10
    } else if (330 >= Number(dates + 1) && Number(dates + 1) > 300) {
      leaseTermss = 11
    } else if (365 >= Number(dates + 1) && Number(dates + 1) > 330) {
      leaseTermss = 12
    }
    let childDay = Number(dates + 1) % 30;
    let childPrice = childDay * this.data.daypricesss;
    if (childPrice < 500 && childPrice != '0') {
      leaseTermss = leaseTermss - 1
    }

    let worryMoneys = this.data.params.tit[cobIndex].term_list[terIndex].specifications[verIndex].money - (this.data.daypricesss + childDay * 1) * Number(dates + 1)
    console.log("55656", worryMoneys)

    let showpriceday = ((this.data.params.tit[cobIndex].term_list[terIndex].specifications[verIndex].money * this.data.totalBuyCounts - worryMoneys * this.data.totalBuyCounts) / Number(dates + 1)).toFixed(2)
    console.log("55656++++", showpriceday)



    // dayPrice: ((this.data.money * this.data.zlnum - this.data.worryMoneys * this.data.zlnum) / this.data.trem_value).toFixed(2)
    // this.setData({
    //   wmoey:wmoey,
    //   dayprice: dayprice
    // })
    // if (Number(dates + 1) < 30){


    //   my.showToast({
    //     type: 'exception ',
    //     content: '起租时间为30天',
    //     duration: 1000,
    //   });
    // }
    this.setData({
      sumdate: Number(dates + 1),
      showpriceday: showpriceday,
      worryMoneys: worryMoneys

    })
    console.log(Number(dates + 1))
  },
  DateDiff(sDate1, sDate2) {
    //sDate1和sDate2是年-月-日格式
    var arrDate, objDate1, objDate2, intDays;
    arrDate = sDate1.split("-");
    objDate1 = new Date(arrDate[1] + '-' + arrDate[2] + '-' + arrDate[0]); //转换为月-日-年格式
    arrDate = sDate2.split("-");
    objDate2 = new Date(arrDate[1] + '-' + arrDate[2] + '-' + arrDate[0]);
    intDays = parseInt(Math.abs(objDate1 - objDate2) / 1000 / 60 / 60 / 24); //把相差的毫秒数转换为天数
    return intDays;
  },
  comSelects() {

    this.setData({
      showCalendar: true
    })

  }
});